{extend name="public:base" /}
{block name="theme"}业务管理{/block}
{block name="small_theme"}新增订单{/block}
{block name="breadcrumb"}
<li><a href="{:url('olist')}">业务列表</a></li>
<li class="active">业务首页</li>
{/block}
{block name="content"}
<style>
	input.error { border: 1px solid red; }
	label.error {
		font-weight: bold;
		color: #EA5200;
	}
</style>
<link rel="stylesheet" href="__CSS__/style.css">
<link rel="stylesheet" href="__CSS__/addcomon.css">
	<div class="row" style="padding:15px;">
		<div class="col-xs-12">
			<div class="box">
				<div class="box-header" data-original-title="" style="height: 40px;">
					<h2>新增顾客订单</h2>
				</div>
				<form  id="commentForm" method="post" action="{:url('add')}" >
					<div class="add-box">
						<div class="box-left">
							<label>顾客信息：</label>
							<div class="form-group add-form-group">
								<label>顾客姓名</label>
								<input type="text" name="name">
							</div>
							<div class="form-group add-form-group">
								<label>妈妈电话</label>
								<input type="text" name="maphone" id="maphone">
							</div>
							<div class="form-group add-form-group">
								<label>家人电话</label>
								<input type="text" name="otherphone" id="otherphone">
							</div>
							<div class="form-group add-form-group">
								<label>微信</label>
								<input type="text" name="weixin" id="weixin">
							</div>
							<div class="form-group add-form-group">
								<label>QQ</label>
								<input type="text" name="qq" id="qq">
							</div>
							<div class="form-group add-form-group">
								<label>预产期</label>
								<!--<input type="text" name="yctime"  onclick="laydate({min: laydate.now()})">-->
								<input type="text" name="yctime"  id="yctime">
							</div>
							<div class="form-group add-form-group">
								<label>业务分类</label>
								<select class="form-control" name="fenlei">
									<!--<option value="">请选择分类</option>-->
									{volist name='fenlei' id='data'}
										<option value="{$data.id}" {eq name="data.id" value="83"}selected{/eq} >{$data.name}</option>
									{/volist}
								</select>
							</div>
							<div class="form-group add-form-group">
								<label>业务状态</label>
								<select class="form-control" name="ywstate">
									{volist name='state' id='data'}
									<option value="{$data.id}" {$data.status} >{$data.name}</option>
									{/volist}
								</select>
							</div>
						</div>

						<div class="box-right">
							<label>渠道信息：</label>
							<div class="form-group add-form-group">
								<label>渠道</label>
								<select class="form-control" name="qudao" id="qudao">
									<option value="">请选择渠道</option>
									{volist name='qudao' id='data'}
									<option value="{$data.id}">{$data.name}</option>
									{/volist}
								</select>
							</div>
							<div class="form-group add-form-group">
								<label>区域</label>
								<select class="form-control" name="area" id="area">
									<option value="">请选择区域</option>
									{volist name='area' id='data'}
									<option value="{$data.id}">{$data.name}</option>
									{/volist}
								</select>
							</div>
							<div class="form-group add-form-group">
								<label>收集医院</label>
								<select class="form-control" name="yiyuan" id="yiyuan">
									<option value="">请选择医院</option>
									{volist name='yiyuan' id='data'}
									<option value="{$data.id}">{$data.name}</option>
									{/volist}
								</select>
							</div>
							<div class="form-group add-form-group">
								<label>医院渠道</label>
								<select class="form-control" name="menzhen" id="menzhen">
									<option value="">请选择门诊</option>
									{volist name='menzhen' id='data'}
									<option value="{$data.id}">{$data.name}</option>
									{/volist}
								</select>
							</div>
							<div class="add-form-group">
								<label>渠道备注</label>
								<textarea type="text" rows="5" name="qdbz"></textarea>
							</div>
						</div>

						<div class="btn-box">
							<button type="submit" class="btn btn-color-o" id="submit">提交</button>
							<button type="button" class="btn btn-color-g" onclick="javascript:history.back(-1);return false;">返回</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
{/block}

{block name="js"}
	<script type="text/javascript" src="__STATIC__/validate/jquery.validate.min.js"></script>
	<script type="text/javascript" src="__STATIC__/validate/jquery.metadata.js"></script>
	<!--<script type="text/javascript" src="__STATIC__/laydate/laydate.js"></script>-->
	<script type="text/javascript" src="__JS__/yewu.js"></script>
	<script type="text/javascript" src="__JS__/chachong.js"></script>

	<script type="text/javascript" src="__STATIC__/laydate5.05/laydate.js"></script>
	<script type="text/javascript" src="__STATIC__/js/laydatetime.js"></script>

	<script type="text/javascript">
		$().ready(function() {
		//杜柳君可以不用填医院信息
		if({$Think.session.admin_user.adminid} == 107){
            $("#area").removeAttr('required');
            $("#yiyuan").removeAttr('required');
            $("#menzhen").removeAttr('required');
		}else{
            $("#area").attr('required','required');
            $("#yiyuan").attr('required','required');
            $("#menzhen").attr('required','required');
		}

			// 在键盘按下并释放及提交后验证提交表单
			$("#commentForm").validate({
				rules: {
					name:      { required : true},
					maphone:   { required : true,isMobile : true},
					otherphone:{ isMobile : true},
					yctime:	   {required : true},
					ywstate:   { required : true},
                    qudao:	   { required : true},
				},
				messages: {
					name: 		"输入顾客姓名",
					maphone: 	{ required:"输入妈妈电话", isMobile:"电话格式不对" },
					otherphone:	"电话格式不对",
					yctime:		"请输入预产期",
					ywstate:	"请选择状态！",
                    qudao:		"请选择渠道！",
					area:		"请选择区域！",
					yiyuan:		"请选择医院！",
					menzhen:	"请选择门诊！",
				},
				submitHandler: function(form)
				{
					$.ajax({
						type: "POST",
						url:  "{:url('add')}",
						data: $(form).serialize(),
						beforeSend:function(){
							$('#submit').attr("disabled","false"); //禁止点击
						},
						success: function(msg){
							//console.log(msg);
							if(msg.status==1){
								$('#submit').attr("disabled","false"); //禁止点击
								layer.msg(msg.info, {icon: 1});
								setTimeout(function(){
									location.href=msg.url;
								},3000); //延迟演示
							}else{
								layer.msg(msg.info, {icon: 2});
								$('#submit').removeAttr("disabled");
							}
						}
					});
				}

			});
			return false;
		});
		highlight_subnav("{:url('olist')}");
	</script>
{/block}